package cs342.uwosh.edu.MyWorldApp.storage;

import android.os.Parcel;
import android.os.Parcelable;

//TODO discuss

public class Friend implements Parcelable, Comparable<Friend> {
	
	public static final int PARCEL_DESCRIPTION = 2;
	public static final Parcelable.Creator<Friend> CREATOR = new Parcelable.Creator<Friend>() {
		public Friend createFromParcel(Parcel in) {     
			return new Friend(in);
		}
		
		public Friend[] newArray(int size) {
		    return new Friend[size];
		}
	};
	
	private String userName;
	private Location location;
	
	public Friend(String userName, Location location) {
		this.setUserName(userName);
		this.setLocation(location);
	}

	public Friend(Parcel in) {
		userName = in.readString();
		location = in.readParcelable(Location.class.getClassLoader());
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void writeToParcel(Parcel out, int arg1) {
		out.writeString(userName);
		out.writeParcelable(location, 0);
	}

	public int compareTo(Friend f) {
		return userName.compareTo(f.getUserName());
	}
	
	public String toString() {
		return userName + "\n" + location.toString();
	}
}
